<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name = "username" class="ins">
    <button class="revert">恢复</button>
</body>
<script>
    let int = document.querySelector(".ins")
    let bnt = document.querySelector(".revert")
    int.addEventListener("keyup", function(){
        if (/^\d+$/.test(this.value)) {
            console.log(this.value, "允许");
            int.style.color = "black";
        }else{
            console.log(this.value, "禁止");
            int.style.color = "red";
        }
    })
</script>
</html>